import requsest from '@/utils/request'
import {Message} from "element-ui";

export const getUserInfo=()=>{
    return requsest({
        method:"Get",
        url:"http://localhost:8080/userInfo/getUserInfo",
    }).then(
        response=>{
            if(response.data.success){
                //  this.$store.commit("SHOW",false);
                return response.data.data;

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
export const getUserById=(userId)=>{
    return requsest({
        method:"Get",
        url:`http://localhost:8080/user/getUserById/${userId}`,
    }).then(
        response=>{
            if(response.data.success){
                //  this.$store.commit("SHOW",false);
                return response.data.data;

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
export const updateUserInfo=(userInfo)=>{
    return requsest({
        method:"Post",
        data:userInfo,
        url:"http://localhost:8080/userInfo/updateUserInfo",

    }).then(
        response=>{
            if(response.data.success){
                //  this.$store.commit("SHOW",false);
                Message.success("保存成功")

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
export const changePassword=(password)=>{
    return requsest({
        method:"POST",
        url:"http://localhost:8080/user/changePassword",
        data:password
    }).then(
        response=>{
            if(response.data.success){
                //  this.$store.commit("SHOW",false);
                Message.success("修改成功")
                  return true;

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
export const toFollow=(userId)=>{
    return requsest({
        method:"Get",
        url:`http://localhost:8080/userfollow/toFollow/${userId}`,
    }).then(
        response=>{
            if(response.data.success){
                //  this.$store.commit("SHOW",false);
                return response.data.data;

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
export const getFollow=(userId)=>{
    return requsest({
        method:"Get",
        url:`http://localhost:8080/userfollow/getFollow/${userId}`,
    }).then(
        response=>{
            if(response.data.success){
                return response.data.data;

            }
        },
        error=>{
            console.log("请求失败"+error.message);
        }

    )
}
